package com.qyhl.webtv.module_user.share;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.gyf.immersionbar.ImmersionBar;
import com.qyhl.webtv.basiclib.base.BaseActivity;
import com.qyhl.webtv.basiclib.base.BaseIViewPresenter;
import com.qyhl.webtv.commonlib.constant.ARouterPathConstant;
import com.qyhl.webtv.module_user.R;
import com.qyhl.webtv.module_user.R2;
import com.weavey.loading.lib.LoadingLayout;

import butterknife.BindView;
import butterknife.OnClick;

@Route(path = ARouterPathConstant.TEACHACTIVITY)
public class TeachActivity extends BaseActivity {
    @BindView(R2.id.webview)
    WebView webview;
    @BindView(R2.id.load_mask)
    LoadingLayout load_mask;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    protected int getContentView() {
        return R.layout.login_activity_teach;
    }

    @Override
    protected void setImmersionBar(ImmersionBar mImmersionBar) {
        setDefaultImmerBar();
    }

    @Override
    protected BaseIViewPresenter initBaseIViewPresenter() {
        return null;
    }

    @Override
    protected void init() {
        inits();
    }

    @Override
    protected void setListener() {

    }

    private void inits() {
        load_mask.setStatus(LoadingLayout.Loading);
        WebSettings settings = webview.getSettings();
        settings.setJavaScriptEnabled(false);
        settings.setDefaultTextEncodingName("utf-8");
        settings.setDomStorageEnabled(true);
        settings.setUseWideViewPort(false);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setSupportZoom(false);
        settings.setBuiltInZoomControls(false);

        webview.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                load_mask.setStatus(LoadingLayout.Success);
            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {

                super.onPageStarted(view, url, favicon);

            }
        });

        webview.loadUrl("http://wxshare.i2863.com/inviteStep/indexStep.html");
        removeWebViewJI(webview);
    }

    @OnClick(R2.id.back)
    public void onClick() {
        finish();
    }
}
